home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Source / GNU / cc / gcc.info-8 (.txt) < prev    next >
GNU Info File  |  1993-10-21  |  43KB  |  754 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.54 from the input
  2. file gcc.texi.
  3.    This file documents the use and the internals of the GNU compiler.
  4.    Published by the Free Software Foundation 675 Massachusetts Avenue
  5. Cambridge, MA 02139 USA
  6.    Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
  7.    Permission is granted to make and distribute verbatim copies of this
  8. manual provided the copyright notice and this permission notice are
  9. preserved on all copies.
  10.    Permission is granted to copy and distribute modified versions of
  11. this manual under the conditions for verbatim copying, provided also
  12. that the sections entitled "GNU General Public License" and "Protect
  13. Your Freedom--Fight `Look And Feel'" are included exactly as in the
  14. original, and provided that the entire resulting derived work is
  15. distributed under the terms of a permission notice identical to this
  16.    Permission is granted to copy and distribute translations of this
  17. manual into another language, under the above conditions for modified
  18. versions, except that the sections entitled "GNU General Public
  19. License" and "Protect Your Freedom--Fight `Look And Feel'", and this
  20. permission notice, may be included in translations approved by the Free
  21. Software Foundation instead of in the original English.
  22. File: gcc.info,  Node: C++ Extensions,  Next: Trouble,  Prev: C Extensions,  Up: Top
  23. Extensions to the C++ Language
  24. ******************************
  25.    The GNU compiler provides these extensions to the C++ language (and
  26. you can also use most of the C language extensions in your C++
  27. programs).  If you want to write code that checks whether these
  28. features are available, you can test for the GNU compiler the same way
  29. as for C programs: check for a predefined macro `__GNUC__'.  You can
  30. also use `__GNUG__' to test specifically for GNU C++ (*note Standard
  31. Predefined Macros: (cpp.info)Standard Predefined.).
  32. * Menu:
  33. * Naming Results::      Giving a name to C++ function return values.
  34. * Min and Max::        C++ Minimum and maximum operators.
  35. * Destructors and Goto:: Goto is safe to use in C++ even when destructors
  36.                            are needed.
  37. * C++ Interface::       You can use a single C++ header file for both
  38.                          declarations and definitions.
  39. File: gcc.info,  Node: Naming Results,  Next: Min and Max,  Up: C++ Extensions
  40. Named Return Values in C++
  41. ==========================
  42.    GNU C++ extends the function-definition syntax to allow you to
  43. specify a name for the result of a function outside the body of the
  44. definition, in C++ programs:
  45.      TYPE
  46.      FUNCTIONNAME (ARGS) return RESULTNAME;
  47.      {
  48.        ...
  49.        BODY
  50.        ...
  51.      }
  52.    You can use this feature to avoid an extra constructor call when a
  53. function result has a class type.  For example, consider a function
  54. `m', declared as `X v = m ();', whose result is of class `X':
  55.      X
  56.      m ()
  57.      {
  58.        X b;
  59.        b.a = 23;
  60.        return b;
  61.      }
  62.    Although `m' appears to have no arguments, in fact it has one
  63. implicit argument: the address of the return value.  At invocation, the
  64. address of enough space to hold `v' is sent in as the implicit argument.
  65. Then `b' is constructed and its `a' field is set to the value 23.
  66. Finally, a copy constructor (a constructor of the form `X(X&)') is
  67. applied to `b', with the (implicit) return value location as the
  68. target, so that `v' is now bound to the return value.
  69.    But this is wasteful.  The local `b' is declared just to hold
  70. something that will be copied right out.  While a compiler that
  71. combined an "elision" algorithm with interprocedural data flow analysis
  72. could conceivably eliminate all of this, it is much more practical to
  73. allow you to assist the compiler in generating efficient code by
  74. manipulating the return value explicitly, thus avoiding the local
  75. variable and copy constructor altogether.
  76.    Using the extended GNU C++ function-definition syntax, you can avoid
  77. the temporary allocation and copying by naming `r' as your return value
  78. as the outset, and assigning to its `a' field directly:
  79.      X
  80.      m () return r;
  81.      {
  82.        r.a = 23;
  83.      }
  84. The declaration of `r' is a standard, proper declaration, whose effects
  85. are executed *before* any of the body of `m'.
  86.    Functions of this type impose no additional restrictions; in
  87. particular, you can execute `return' statements, or return implicitly by
  88. reaching the end of the function body ("falling off the edge").  Cases
  89.      X
  90.      m () return r (23);
  91.      {
  92.        return;
  93.      }
  94. (or even `X m () return r (23); { }') are unambiguous, since the return
  95. value `r' has been initialized in either case.  The following code may
  96. be hard to read, but also works predictably:
  97.      X
  98.      m () return r;
  99.      {
  100.        X b;
  101.        return b;
  102.      }
  103.    The return value slot denoted by `r' is initialized at the outset,
  104. but the statement `return b;' overrides this value.  The compiler deals
  105. with this by destroying `r' (calling the destructor if there is one, or
  106. doing nothing if there is not), and then reinitializing `r' with `b'.
  107.    This extension is provided primarily to help people who use
  108. overloaded operators, where there is a great need to control not just
  109. the arguments, but the return values of functions.  For classes where
  110. the copy constructor incurs a heavy performance penalty (especially in
  111. the common case where there is a quick default constructor), this is a
  112. major savings.  The disadvantage of this extension is that you do not
  113. control when the default constructor for the return value is called: it
  114. is always called at the beginning.
  115. File: gcc.info,  Node: Min and Max,  Next: Destructors and Goto,  Prev: Naming Results,  Up: C++ Extensions
  116. Minimum and Maximum Operators in C++
  117. ====================================
  118.    It is very convenient to have operators which return the "minimum"
  119. or the "maximum" of two arguments.  In GNU C++ (but not in GNU C),
  120. `A <? B'
  121.      is the "minimum", returning the smaller of the numeric values A
  122.      and B;
  123. `A >? B'
  124.      is the "maximum", returning the larger of the numeric values A and
  125.      B.
  126.    These operations are not primitive in ordinary C++, since you can
  127. use a macro to return the minimum of two things in C++, as in the
  128. following example.
  129.      #define MIN(X,Y) ((X) < (Y) ? : (X) : (Y))
  130. You might then use `int min = MIN (i, j);' to set MIN to the minimum
  131. value of variables I and J.
  132.    However, side effects in `X' or `Y' may cause unintended behavior.
  133. For example, `MIN (i++, j++)' will fail, incrementing the smaller
  134. counter twice.  A GNU C extension allows you to write safe macros that
  135. avoid this kind of problem (*note Naming an Expression's Type: Naming
  136. Types.).  However, writing `MIN' and `MAX' as macros also forces you to
  137. use function-call notation notation for a fundamental arithmetic
  138. operation.  Using GNU C++ extensions, you can write `int min = i <? j;'
  139. instead.
  140.    Since `<?' and `>?' are built into the compiler, they properly
  141. handle expressions with side-effects;  `int min = i++ <? j++;' works
  142. correctly.
  143. File: gcc.info,  Node: Destructors and Goto,  Next: C++ Interface,  Prev: Min and Max,  Up: C++ Extensions
  144. `goto' and Destructors in GNU C++
  145. =================================
  146.    In C++ programs, you can safely use the `goto' statement.  When you
  147. use it to exit a block which contains aggregates requiring destructors,
  148. the destructors will run before the `goto' transfers control.  (In ANSI
  149. C++, `goto' is restricted to targets within the current block.)
  150.    The compiler still forbids using `goto' to *enter* a scope that
  151. requires constructors.
  152. File: gcc.info,  Node: C++ Interface,  Prev: Destructors and Goto,  Up: C++ Extensions
  153. Declarations and Definitions in One Header
  154. ==========================================
  155.    C++ object definitions can be quite complex.  In principle, your
  156. source code will need two kinds of things for each object that you use
  157. across more than one source file.  First, you need an "interface"
  158. specification, describing its structure with type declarations and
  159. function prototypes.  Second, you need the "implementation" itself.  It
  160. can be tedious to maintain a separate interface description in a header
  161. file, in parallel to the actual implementation.  It is also dangerous,
  162. since separate interface and implementation definitions may not remain
  163. parallel.
  164.    With GNU C++, you can use a single header file for both purposes.
  165.      *Warning:* The mechanism to specify this is in transition.  For the
  166.      nonce, you must use one of two `#pragma' commands; in a future
  167.      release of GNU C++, an alternative mechanism will make these
  168.      `#pragma' commands unnecessary.
  169.    The header file contains the full definitions, but is marked with
  170. `#pragma interface' in the source code.  This allows the compiler to
  171. use the header file only as an interface specification when ordinary
  172. source files incorporate it with `#include'.  In the single source file
  173. where the full implementation belongs, you can use either a naming
  174. convention or `#pragma implementation' to indicate this alternate use
  175. of the header file.
  176. `#pragma interface'
  177.      Use this directive in *header files* that define object classes,
  178.      to save space in most of the object files that use those classes.
  179.      Normally, local copies of certain information (backup copies of
  180.      inline member functions, debugging information, and the internal
  181.      tables that implement virtual functions) must be kept in each
  182.      object file that includes class definitions.  You can use this
  183.      pragma to avoid such duplication.  When a header file containing
  184.      `#pragma interface' is included in a compilation, this auxiliary
  185.      information will not be generated (unless the main input source
  186.      file itself uses `#pragma implementation').  Instead, the object
  187.      files will contain references to be resolved at link time.
  188. `#pragma implementation'
  189. `#pragma implementation "OBJECTS.h"'
  190.      Use this pragma in a *main input file*, when you want full output
  191.      from included header files to be generated (and made globally
  192.      visible).  The included header file, in turn, should use `#pragma
  193.      interface'.  Backup copies of inline member functions, debugging
  194.      information, and the internal tables used to implement virtual
  195.      functions are all generated in implementation files.
  196.      `#pragma implementation' is *implied* whenever the basename(1) of
  197.      your source file matches the basename of a header file it
  198.      includes.  There is no way to turn this off (other than using a
  199.      different name for one of the two files).  In the same vein, if
  200.      you use `#pragma implementation' with no argument, it applies to an
  201.      include file with the same basename as your source file.  For
  202.      example, in `allclass.cc', `#pragma implementation' by itself is
  203.      equivalent to `#pragma implementation "allclass.h"'; but even if
  204.      you do not say `#pragma implementation' at all, `allclass.h' is
  205.      treated as an implementation file whenever you include it from
  206.      `allclass.cc'.
  207.      If you use an explicit `#pragma implementation', it must appear in
  208.      your source file *before* you include the affected header files.
  209.      Use the string argument if you want a single implementation file to
  210.      include code from multiple header files.  (You must also use
  211.      `#include' to include the header file; `#pragma implementation'
  212.      only specifies how to use the file--it doesn't actually include
  213.      it.)
  214.      There is no way to split up the contents of a single header file
  215.      into multiple implementation files.
  216.    `#pragma implementation' and `#pragma interface' also have an effect
  217. on function inlining.
  218.    If you define a class in a header file marked with `#pragma
  219. interface', the effect on a function defined in that class is similar to
  220. an explicit `extern' declaration--the compiler emits no code at all to
  221. define an independent version of the function.  Its definition is used
  222. only for inlining with its callers.
  223.    Conversely, when you include the same header file in a main source
  224. file that declares it as `#pragma implementation', the compiler emits
  225. code for the function itself; this defines a version of the function
  226. that can be found via pointers (or by callers compiled without
  227. inlining).
  228.    ---------- Footnotes ----------
  229.    (1)  A file's "basename" is the name stripped of all leading path
  230. information and of trailing suffixes, such as `.h' or `.C' or `.cc'.
  231. File: gcc.info,  Node: Trouble,  Next: Bugs,  Prev: C++ Extensions,  Up: Top
  232. Known Causes of Trouble with GNU CC
  233. ***********************************
  234.    This section describes known problems that affect users of GNU CC.
  235. Most of these are not GNU CC bugs per se--if they were, we would fix
  236. them.  But the result for a user may be like the result of a bug.
  237.    Some of these problems are due to bugs in other software, some are
  238. missing features that are too much work to add, and some are places
  239. where people's opinions differ as to what is best.
  240. * Menu:
  241. * Actual Bugs::              Bugs we will fix later.
  242. * Installation Problems::     Problems that manifest when you install GNU CC.
  243. * Cross-Compiler Problems::   Common problems of cross compiling with GNU CC.
  244. * Interoperation::      Problems using GNU CC with other compilers,
  245.                and with certain linkers, assemblers and debuggers.
  246. * External Bugs::    Problems compiling certain programs.
  247. * Incompatibilities::   GNU CC is incompatible with traditional C.
  248. * Fixed Headers::       GNU C uses corrected versions of system header files.
  249.                            This is necessary, but doesn't always work smoothly.
  250. * Disappointments::     Regrettable things we can't change, but not quite bugs.
  251. * C++ Misunderstandings::     Common misunderstandings with GNU C++.
  252. * Protoize Caveats::    Things to watch out for when using `protoize'.
  253. * Non-bugs::        Things we think are right, but some others disagree.
  254. * Warnings and Errors:: Which problems in your code get warnings,
  255.                          and which get errors.
  256. File: gcc.info,  Node: Actual Bugs,  Next: Installation Problems,  Up: Trouble
  257. Actual Bugs We Haven't Fixed Yet
  258. ================================
  259.    * The `fixincludes' script interacts badly with automounters; if the
  260.      directory of system header files is automounted, it tends to be
  261.      unmounted while `fixincludes' is running.  This would seem to be a
  262.      bug in the automounter.  We don't know any good way to work around
  263.      it.
  264.    * Loop unrolling doesn't work properly for certain C++ programs.
  265.      This is because of difficulty in updating the debugging
  266.      information within the loop being unrolled.  We plan to revamp the
  267.      representation of debugging information so that this will work
  268.      properly, but we have not done this in version 2.5 because we
  269.      don't want to delay it any further.
  270. File: gcc.info,  Node: Installation Problems,  Next: Cross-Compiler Problems,  Prev: Actual Bugs,  Up: Trouble
  271. Installation Problems
  272. =====================
  273.    This is a list of problems (and some apparent problems which don't
  274. really mean anything is wrong) that show up during installation of GNU
  275.    * On certain systems, defining certain environment variables such as
  276.      `CC' can interfere with the functioning of `make'.
  277.    * If you encounter seemingly strange errors when trying to build the
  278.      compiler in a directory other than the source directory, it could
  279.      be because you have previously configured the compiler in the
  280.      source directory.  Make sure you have done all the necessary
  281.      preparations.  *Note Other Dir::.
  282.    * In previous versions of GNU CC, the `gcc' driver program looked for
  283.      `as' and `ld' in various places; for example, in files beginning
  284.      with `/usr/local/lib/gcc-'.  GNU CC version 2 looks for them in
  285.      the directory `/usr/local/lib/gcc-lib/TARGET/VERSION'.
  286.      Thus, to use a version of `as' or `ld' that is not the system
  287.      default, for example `gas' or GNU `ld', you must put them in that
  288.      directory (or make links to them from that directory).
  289.    * Some commands executed when making the compiler may fail (return a
  290.      non-zero status) and be ignored by `make'.  These failures, which
  291.      are often due to files that were not found, are expected, and can
  292.      safely be ignored.
  293.    * It is normal to have warnings in compiling certain files about
  294.      unreachable code and about enumeration type clashes.  These files'
  295.      names begin with `insn-'.  Also, `real.c' may get some warnings
  296.      that you can ignore.
  297.    * Sometimes `make' recompiles parts of the compiler when installing
  298.      the compiler.  In one case, this was traced down to a bug in
  299.      `make'.  Either ignore the problem or switch to GNU Make.
  300.    * If you have installed a program known as purify, you may find that
  301.      it causes errors while linking `enquire', which is part of building
  302.      GNU CC.  The fix is to get rid of the file `real-ld' which purify
  303.      installs--so that GNU CC won't try to use it.
  304.    * On Linux SLS 1.01, there is a problem with `libc.a': it does not
  305.      contain the obstack functions.  However, GNU CC assumes that the
  306.      obstack functions are in `libc.a' when it is the GNU C library.
  307.      To work around this problem, change the `__GNU_LIBRARY__'
  308.      conditional around line 31 to `#if 1'.
  309.    * On some 386 systems, building the compiler never finishes because
  310.      `enquire' hangs due to a hardware problem in the motherboard--it
  311.      reports floating point exceptions to the kernel incorrectly.  You
  312.      can install GNU CC except for `float.h' by patching out the
  313.      command to run `enquire'.  You may also be able to fix the problem
  314.      for real by getting a replacement motherboard.  This problem was
  315.      observed in Revision E of the Micronics motherboard, and is fixed
  316.      in Revision F.  It has also been observed in the MYLEX MXA-33
  317.      motherboard.
  318.      If you encounter this problem, you may also want to consider
  319.      removing the FPU from the socket during the compilation.
  320.      Alternatively, if you are running SCO Unix, you can reboot and
  321.      force the FPU to be ignored.  To do this, type `hd(40)unix auto
  322.      ignorefpu'.
  323.    * On some 386 systems, GNU CC crashes trying to compile `enquire.c'.
  324.      This happens on machines that don't have a 387 FPU chip.  On 386
  325.      machines, the system kernel is supposed to emulate the 387 when you
  326.      don't have one.  The crash is due to a bug in the emulator.
  327.      One of these systems is the Unix from Interactive Systems: 386/ix.
  328.      On this system, an alternate emulator is provided, and it does
  329.      work.  To use it, execute this command as super-user:
  330.           ln /etc/emulator.rel1 /etc/emulator
  331.      and then reboot the system.  (The default emulator file remains
  332.      present under the name `emulator.dflt'.)
  333.      Try using `/etc/emulator.att', if you have such a problem on the
  334.      SCO system.
  335.      Another system which has this problem is Esix.  We don't know
  336.      whether it has an alternate emulator that works.
  337.      On NetBSD 0.8, a similar problem manifests itself as these error
  338.      messages:
  339.           enquire.c: In function `fprop':
  340.           enquire.c:2328: floating overflow
  341.    * On SCO systems, when compiling GNU CC with the system's compiler,
  342.      do not use `-O'.  Some versions of the system's compiler miscompile
  343.      GNU CC with `-O'.
  344.    * Sometimes on a Sun 4 you may observe a crash in the program
  345.      `genflags' or `genoutput' while building GNU CC.  This is said to
  346.      be due to a bug in `sh'.  You can probably get around it by running
  347.      `genflags' or `genoutput' manually and then retrying the `make'.
  348.    * On Solaris 2, executables of GNU CC version 2.0.2 are commonly
  349.      available, but they have a bug that shows up when compiling current
  350.      versions of GNU CC: undefined symbol errors occur during assembly
  351.      if you use `-g'.
  352.      The solution is to compile the current version of GNU CC without
  353.      `-g'.  That makes a working compiler which you can use to recompile
  354.      with `-g'.
  355.    * Solaris 2 comes with a number of optional OS packages.  Some of
  356.      these packages are needed to use GNU CC fully.  If you did not
  357.      install all optional packages when installing Solaris, you will
  358.      need to verify that the packages that GNU CC needs are installed.
  359.      To check whether an optional package is installed, use the
  360.      `pkginfo' command.  To add an optional package, use the `pkgadd'
  361.      command.  For further details, see the Solaris documentation.
  362.      For Solaris 2.0 and 2.1, GNU CC needs six packages: `SUNWarc',
  363.      `SUNWbtool', `SUNWesu', `SUNWhea', `SUNWlibm', and `SUNWtoo'.
  364.      For Solaris 2.2, GNU CC needs an additional seventh package:
  365.      `SUNWsprot'.
  366.    * On Solaris 2, trying to use the linker and other tools in
  367.      `/usr/ucb' to install GNU CC has been observed to cause trouble.
  368.      For example, the linker may hang indefinitely.  The fix is to
  369.      remove `/usr/ucb' from your `PATH'.
  370.    * If you use the 1.31 version of the MIPS assembler (such as was
  371.      shipped with Ultrix 3.1), you will need to use the
  372.      -fno-delayed-branch switch when optimizing floating point code.
  373.      Otherwise, the assembler will complain when the GCC compiler fills
  374.      a branch delay slot with a floating point instruction, such as
  375.      add.d.
  376.    * If on a MIPS system you get an error message saying "does not have
  377.      gp sections for all it's [sic] sectons [sic]", don't worry about
  378.      it.  This happens whenever you use GAS with the MIPS linker, but
  379.      there is not really anything wrong, and it is okay to use the
  380.      output file.  You can stop such warnings by installing the GNU
  381.      linker.
  382.      It would be nice to extend GAS to produce the gp tables, but they
  383.      are optional, and there should not be a warning about their
  384.      absence.
  385.    * Users have reported some problems with version 2.0 of the MIPS
  386.      compiler tools that were shipped with Ultrix 4.1.  Version 2.10
  387.      which came with Ultrix 4.2 seems to work fine.
  388.    * Some versions of the MIPS linker will issue an assertion failure
  389.      when linking code that uses `alloca' against shared libraries on
  390.      RISC-OS 5.0, and DEC's OSF/1 systems.  This is a bug in the
  391.      linker, that is supposed to be fixed in future revisions.  To
  392.      protect against this, GCC passes `-non_shared' to the linker
  393.      unless you pass an explicit `-shared' or `-call_shared' switch.
  394.    * On System V release 3, you may get this error message while
  395.      linking:
  396.           ld fatal: failed to write symbol name SOMETHING
  397.            in strings table for file WHATEVER
  398.      This probably indicates that the disk is full or your ULIMIT won't
  399.      allow the file to be as large as it needs to be.
  400.      This problem can also result because the kernel parameter `MAXUMEM'
  401.      is too small.  If so, you must regenerate the kernel and make the
  402.      value much larger.  The default value is reported to be 1024; a
  403.      value of 32768 is said to work.  Smaller values may also work.
  404.    * On System V, if you get an error like this,
  405.           /usr/local/lib/bison.simple: In function `yyparse':
  406.           /usr/local/lib/bison.simple:625: virtual memory exhausted
  407.      that too indicates a problem with disk space, ULIMIT, or `MAXUMEM'.
  408.    * Current GNU CC versions probably do not work on version 2 of the
  409.      NeXT operating system.
  410.    * On the Tower models 4N0 and 6N0, by default a process is not
  411.      allowed to have more than one megabyte of memory.  GNU CC cannot
  412.      compile itself (or many other programs) with `-O' in that much
  413.      memory.
  414.      To solve this problem, reconfigure the kernel adding the following
  415.      line to the configuration file:
  416.           MAXUMEM = 4096
  417.    * On HP 9000 series 300 or 400 running HP-UX release 8.0, there is a
  418.      bug in the assembler that must be fixed before GNU CC can be
  419.      built.  This bug manifests itself during the first stage of
  420.      compilation, while building `libgcc2.a':
  421.           _floatdisf
  422.           cc1: warning: `-g' option not supported on this version of GCC
  423.           cc1: warning: `-g1' option not supported on this version of GCC
  424.           ./xgcc: Internal compiler error: program as got fatal signal 11
  425.      A patched version of the assembler is available by anonymous ftp
  426.      from `altdorf.ai.mit.edu' as the file
  427.      `archive/cph/hpux-8.0-assembler'.  If you have HP software support,
  428.      the patch can also be obtained directly from HP, as described in
  429.      the following note:
  430.           This is the patched assembler, to patch SR#1653-010439, where
  431.           the assembler aborts on floating point constants.
  432.           The bug is not really in the assembler, but in the shared
  433.           library version of the function "cvtnum(3c)".  The bug on
  434.           "cvtnum(3c)" is SR#4701-078451.  Anyway, the attached
  435.           assembler uses the archive library version of "cvtnum(3c)"
  436.           and thus does not exhibit the bug.
  437.      This patch is also known as PHCO_0800.
  438.    * Some versions of the Pyramid C compiler are reported to be unable
  439.      to compile GNU CC.  You must use an older version of GNU CC for
  440.      bootstrapping.  One indication of this problem is if you get a
  441.      crash when GNU CC compiles the function `muldi3' in file
  442.      `libgcc2.c'.
  443.      You may be able to succeed by getting GNU CC version 1, installing
  444.      it, and using it to compile GNU CC version 2.  The bug in the
  445.      Pyramid C compiler does not seem to affect GNU CC version 1.
  446.    * There may be similar problems on System V Release 3.1 on 386
  447.      systems.
  448.    * On the Altos 3068, programs compiled with GNU CC won't work unless
  449.      you fix a kernel bug.  This happens using system versions V.2.2
  450.      1.0gT1 and V.2.2 1.0e and perhaps later versions as well.  See the
  451.      file `README.ALTOS'.
  452.    * You will get several sorts of compilation and linking errors on the
  453.      we32k if you don't follow the special instructions.  *Note WE32K
  454.      Install::.
  455. File: gcc.info,  Node: Cross-Compiler Problems,  Next: Interoperation,  Prev: Installation Problems,  Up: Trouble
  456. Cross-Compiler Problems
  457. =======================
  458.    You may run into problems with cross compilation on certain machines,
  459. for several reasons.
  460.    * Cross compilation can run into trouble for certain machines because
  461.      some target machines' assemblers require floating point numbers to
  462.      be written as *integer* constants in certain contexts.
  463.      The compiler writes these integer constants by examining the
  464.      floating point value as an integer and printing that integer,
  465.      because this is simple to write and independent of the details of
  466.      the floating point representation.  But this does not work if the
  467.      compiler is running on a different machine with an incompatible
  468.      floating point format, or even a different byte-ordering.
  469.      In addition, correct constant folding of floating point values
  470.      requires representing them in the target machine's format.  (The C
  471.      standard does not quite require this, but in practice it is the
  472.      only way to win.)
  473.      It is now possible to overcome these problems by defining macros
  474.      such as `REAL_VALUE_TYPE'.  But doing so is a substantial amount of
  475.      work for each target machine.  *Note Cross-compilation::.
  476.    * At present, the program `mips-tfile' which adds debug support to
  477.      object files on MIPS systems does not work in a cross compile
  478.      environment.
  479. File: gcc.info,  Node: Interoperation,  Next: External Bugs,  Prev: Cross-Compiler Problems,  Up: Trouble
  480. Interoperation
  481. ==============
  482.    This section lists various difficulties encountered in using GNU C or
  483. GNU C++ together with other compilers or with the assemblers, linkers,
  484. libraries and debuggers on certain systems.
  485.    * If you are using version 2.3 of libg++, you need to rebuild it with
  486.      `make CC=gcc' to avoid mismatches in the definition of `size_t'.
  487.    * Objective C does not work on the RS/6000 or the Alpha.
  488.    * GNU C++ does not do name mangling in the same way as other C++
  489.      compilers.  This means that object files compiled with one compiler
  490.      cannot be used with another.
  491.      This effect is intentional, to protect you from more subtle
  492.      problems.  Compilers differ as to many internal details of C++
  493.      implementation, including: how class instances are laid out, how
  494.      multiple inheritance is implemented, and how virtual function
  495.      calls are handled.  If the name encoding were made the same, your
  496.      programs would link against libraries provided from other
  497.      compilers--but the programs would then crash when run.
  498.      Incompatible libraries are then detected at link time, rather than
  499.      at run time.
  500.    * Older GDB versions sometimes fail to read the output of GNU CC
  501.      version 2.  If you have trouble, get GDB version 4.4 or later.
  502.    * DBX rejects some files produced by GNU CC, though it accepts
  503.      similar constructs in output from PCC.  Until someone can supply a
  504.      coherent description of what is valid DBX input and what is not,
  505.      there is nothing I can do about these problems.  You are on your
  506.      own.
  507.    * The GNU assembler (GAS) does not support PIC.  To generate PIC
  508.      code, you must use some other assembler, such as `/bin/as'.
  509.    * On some BSD systems including some versions of Ultrix, use of
  510.      profiling causes static variable destructors (currently used only
  511.      in C++) not to be run.
  512.    * Use of `-I/usr/include' may cause trouble.
  513.      Many systems come with header files that won't work with GNU CC
  514.      unless corrected by `fixincludes'.  The corrected header files go
  515.      in a new directory; GNU CC searches this directory before
  516.      `/usr/include'.  If you use `-I/usr/include', this tells GNU CC to
  517.      search `/usr/include' earlier on, before the corrected headers.
  518.      The result is that you get the uncorrected header files.
  519.      Instead, you should use these options (when compiling C programs):
  520.           -I/usr/local/lib/gcc-lib/TARGET/VERSION/include -I/usr/include
  521.      For C++ programs, GNU CC also uses a special directory that
  522.      defines C++ interfaces to standard C subroutines.  This directory
  523.      is meant to be searched *before* other standard include
  524.      directories, so that it takes precedence.  If you are compiling
  525.      C++ programs and specifying include directories explicitly, use
  526.      this option first, then the two options above:
  527.           -I/usr/local/lib/g++-include
  528.    * On a Sparc, GNU CC aligns all values of type `double' on an 8-byte
  529.      boundary, and it expects every `double' to be so aligned.  The Sun
  530.      compiler usually gives `double' values 8-byte alignment, with one
  531.      exception: function arguments of type `double' may not be aligned.
  532.      As a result, if a function compiled with Sun CC takes the address
  533.      of an argument of type `double' and passes this pointer of type
  534.      `double *' to a function compiled with GNU CC, dereferencing the
  535.      pointer may cause a fatal signal.
  536.      One way to solve this problem is to compile your entire program
  537.      with GNU CC.  Another solution is to modify the function that is
  538.      compiled with Sun CC to copy the argument into a local variable;
  539.      local variables are always properly aligned.  A third solution is
  540.      to modify the function that uses the pointer to dereference it via
  541.      the following function `access_double' instead of directly with
  542.      `*':
  543.           inline double
  544.           access_double (double *unaligned_ptr)
  545.           {
  546.             union d2i { double d; int i[2]; };
  547.           
  548.             union d2i *p = (union d2i *) unaligned_ptr;
  549.             union d2i u;
  550.           
  551.             u.i[0] = p->i[0];
  552.             u.i[1] = p->i[1];
  553.           
  554.             return u.d;
  555.           }
  556.      Storing into the pointer can be done likewise with the same union.
  557.    * On Solaris, the `malloc' function in the `libmalloc.a' library may
  558.      allocate memory that is only 4 byte aligned.  Since GNU CC on the
  559.      Sparc assumes that doubles are 8 byte aligned, this may result in a
  560.      fatal signal if doubles are stored in memory allocated by the
  561.      `libmalloc.a' library.
  562.      The solution is to not use the `libmalloc.a' library.  Use instead
  563.      `malloc' and related functions from `libc.a'; they do not have
  564.      this problem.
  565.    * On a Sun, linking using GNU CC fails to find a shared library and
  566.      reports that the library doesn't exist at all.
  567.      This happens if you are using the GNU linker, because it does only
  568.      static linking and looks only for unshared libraries.  If you have
  569.      a shared library with no unshared counterpart, the GNU linker
  570.      won't find anything.
  571.      We hope to make a linker which supports Sun shared libraries, but
  572.      please don't ask when it will be finished--we don't know.
  573.    * Sun forgot to include a static version of `libdl.a' with some
  574.      versions of SunOS (mainly 4.1).  This results in undefined symbols
  575.      when linking static binaries (that is, if you use `-static').  If
  576.      you see undefined symbols `_dlclose', `_dlsym' or `_dlopen' when
  577.      linking, compile and link against the file `mit/util/misc/dlsym.c'
  578.      from the MIT version of X windows.
  579.    * The 128-bit long double format that the Sparc port supports
  580.      currently works by using the architecturally defined quad-word
  581.      floating point instructions.  Since there is no hardware that
  582.      supports these instructions they must be emulated by the operating
  583.      system.  Long doubles do not work in Sun OS versions 4.0.3 and
  584.      earlier, because the kernel eumulator uses an obsolete and
  585.      incompatible format.  Long doubles do not work in Sun OS versions
  586.      4.1.1 to 4.1.3 because of emululator bugs that cause random
  587.      unpredicatable failures.  Long doubles appear to work in Sun OS 5.x
  588.      (Solaris 2.x).
  589.      A future implementation of the sparc long double support will use
  590.      functions calls to library routines instead of the quad-word
  591.      floating point instructions.  This will allow long doubles to work
  592.      in more situtations, since one can then substitute a working
  593.      library if the kernel emulator is buggy.
  594.    * On HP-UX version 9.01 on the HP PA, the HP compiler `cc' does not
  595.      compile GNU CC correctly.  We do not yet know why.  However, GNU CC
  596.      compiled on earlier HP-UX versions works properly on HP-UX 9.01
  597.      and can compile itself properly on 9.01.
  598.    * On the HP PA machine, ADB sometimes fails to work on functions
  599.      compiled with GNU CC.  Specifically, it fails to work on functions
  600.      that use `alloca' or variable-size arrays.  This is because GNU CC
  601.      doesn't generate HP-UX unwind descriptors for such functions.  It
  602.      may even be impossible to generate them.
  603.    * Debugging (`-g') is not supported on the HP PA machine, unless you
  604.      use the preliminary GNU tools (*note Installation::.).
  605.    * Taking the address of a label may generate errors from the HP-UX
  606.      PA assembler.  GAS for the PA does not have this problem.
  607.    * Using floating point parameters for indirect calls to static
  608.      functions will not work when using the HP assembler.  There simply
  609.      is no way for GCC to specify what registers hold arguments for
  610.      static functions when using the HP assembler.  GAS for the PA does
  611.      not have this problem.
  612.    * For some very large functions you may receive errors from the HP
  613.      linker complaining about an out of bounds unconditional branch
  614.      offset.  Fixing this problem correctly requires fixing problems in
  615.      GNU CC and GAS.  We hope to fix this in time for GNU CC 2.6.
  616.      Until then you can work around by making your function smaller,
  617.      and if you are using GAS, splitting the function into multiple
  618.      source files may be necessary.
  619.    * GNU CC compiled code sometimes emits warnings from the HP-UX
  620.      assembler of the form:
  621.           (warning) Use of GR3 when
  622.             frame >= 8192 may cause conflict.
  623.      These warnings are harmless and can be safely ignored.
  624.    * The current version of the assembler (`/bin/as') for the RS/6000
  625.      has certain problems that prevent the `-g' option in GCC from
  626.      working.  Note that `Makefile.in' uses `-g' by default when
  627.      compiling `libgcc2.c'.
  628.      IBM has produced a fixed version of the assembler.  The upgraded
  629.      assembler unfortunately was not included in any of the AIX 3.2
  630.      update PTF releases (3.2.2, 3.2.3, or 3.2.3e).  Users of AIX 3.1
  631.      should request PTF U403044 from IBM and users of AIX 3.2 should
  632.      request PTF U416277.  See the file `README.RS6000' for more
  633.      details on these updates.
  634.      You can test for the presense of a fixed assembler by using the
  635.      command
  636.           as -u < /dev/null
  637.      If the command exits normally, the assembler fix already is
  638.      installed.  If the assembler complains that "-u" is an unknown
  639.      flag, you need to order the fix.
  640.    * On the IBM RS/6000, compiling code of the form
  641.           extern int foo;
  642.           
  643.           ... foo ...
  644.           
  645.           static int foo;
  646.      will cause the linker to report an undefined symbol `foo'.
  647.      Although this behavior differs from most other systems, it is not a
  648.      bug because redefining an `extern' variable as `static' is
  649.      undefined in ANSI C.
  650.    * AIX on the RS/6000 provides support (NLS) for environments outside
  651.      of the United States.  Compilers and assemblers use NLS to support
  652.      locale-specific representations of various objects including
  653.      floating-point numbers ("." vs "," for separating decimal
  654.      fractions).  There have been problems reported where the library
  655.      linked with GCC does not produce the same floating-point formats
  656.      that the assembler accepts.  If you have this problem, set the
  657.      LANG environment variable to "C" or "En_US".
  658.    * On the RS/6000, XLC version 1.3.0.0 will miscompile `jump.c'.  XLC
  659.      version 1.3.0.1 or later fixes this problem.  We do not yet have a
  660.      PTF number for this fix.
  661.    * There is an assembler bug in versions of DG/UX prior to 5.4.2.01
  662.      that occurs when the `fldcr' instruction is used.  GNU CC uses
  663.      `fldcr' on the 88100 to serialize volatile memory references.  Use
  664.      the option `-mno-serialize-volatile' if your version of the
  665.      assembler has this bug.
  666.    * On VMS, GAS versions 1.38.1 and earlier may cause spurious warning
  667.      messages from the linker.  These warning messages complain of
  668.      mismatched psect attributes.  You can ignore them.  *Note VMS
  669.      Install::.
  670.    * On NewsOS version 3, if you include both of the files `stddef.h'
  671.      and `sys/types.h', you get an error because there are two typedefs
  672.      of `size_t'.  You should change `sys/types.h' by adding these
  673.      lines around the definition of `size_t':
  674.           #ifndef _SIZE_T
  675.           #define _SIZE_T
  676.           ACTUAL TYPEDEF HERE
  677.           #endif
  678.    * On the Alliant, the system's own convention for returning
  679.      structures and unions is unusual, and is not compatible with GNU
  680.      CC no matter what options are used.
  681.    * On the IBM RT PC, the MetaWare HighC compiler (hc) uses a different
  682.      convention for structure and union returning.  Use the option
  683.      `-mhc-struct-return' to tell GNU CC to use a convention compatible
  684.      with it.
  685.    * On Ultrix, the Fortran compiler expects registers 2 through 5 to
  686.      be saved by function calls.  However, the C compiler uses
  687.      conventions compatible with BSD Unix: registers 2 through 5 may be
  688.      clobbered by function calls.
  689.      GNU CC uses the same convention as the Ultrix C compiler.  You can
  690.      use these options to produce code compatible with the Fortran
  691.      compiler:
  692.           -fcall-saved-r2 -fcall-saved-r3 -fcall-saved-r4 -fcall-saved-r5
  693.    * On the WE32k, you may find that programs compiled with GNU CC do
  694.      not work with the standard shared C ilbrary.  You may need to link
  695.      with the ordinary C compiler.  If you do so, you must specify the
  696.      following options:
  697.           -L/usr/local/lib/gcc-lib/we32k-att-sysv/2.5 -lgcc -lc_s
  698.      The first specifies where to find the library `libgcc.a' specified
  699.      with the `-lgcc' option.
  700.      GNU CC does linking by invoking `ld', just as `cc' does, and there
  701.      is no reason why it *should* matter which compilation program you
  702.      use to invoke `ld'.  If someone tracks this problem down, it can
  703.      probably be fixed easily.
  704.    * On the Alpha, you may get assembler errors about invalid syntax as
  705.      a result of floating point constants.  This is due to a bug in the
  706.      C library functions `ecvt', `fcvt' and `gcvt'.  Given valid
  707.      floating point numbers, they sometimes print `NaN'.
  708.    * On Irix 4.0.5F (and perhaps in some other versions), an assembler
  709.      bug sometimes reorders instructions incorrectly when optimization
  710.      is turned on.  If you think this may be happening to you, try
  711.      using the GNU assembler; GAS version 2.1 supports ECOFF on Irix.
  712.      Or use the `-noasmopt' option when you compile GNU CC with itself,
  713.      and then again when you compile your program.  (This is a temporary
  714.      kludge to turn off assembler optimization on Irix.)  If this
  715.      proves to be what you need, edit the assembler spec in the file
  716.      `specs' so that it unconditionally passes `-O0' to the assembler,
  717.      and never passes `-O2' or `-O3'.
  718. File: gcc.info,  Node: External Bugs,  Next: Incompatibilities,  Prev: Interoperation,  Up: Trouble
  719. Problems Compiling Certain Programs
  720. ===================================
  721.    * Parse errors may occur compiling X11 on a Decstation running
  722.      Ultrix 4.2 because of problems in DEC's versions of the X11 header
  723.      files `X11/Xlib.h' and `X11/Xutil.h'.  People recommend adding
  724.      `-I/usr/include/mit' to use the MIT versions of the header files,
  725.      using the `-traditional' switch to turn off ANSI C, or fixing the
  726.      header files by adding this:
  727.           #ifdef __STDC__
  728.           #define NeedFunctionPrototypes 0
  729.           #endif
  730.    * If you have trouble compiling Perl on a SunOS 4 system, it may be
  731.      because Perl specifies `-I/usr/ucbinclude'.  This accesses the
  732.      unfixed header files.  Perl specifies the options
  733.           -traditional -Dvolatile=__volatile__
  734.           -I/usr/include/sun -I/usr/ucbinclude
  735.           -fpcc-struct-return
  736.      all of which are unnecessary with GCC 2.4.5 and newer versions.
  737.      You can make a properly working Perl by setting `ccflags' and
  738.      `cppflags' to empty values in `config.sh', then typing `./doSH;
  739.      make depend; make'.
  740.    * On various 386 Unix systems derived from System V, including SCO,
  741.      ISC, and ESIX, you may get error messages about running out of
  742.      virtual memory while compiling certain programs.
  743.      You can prevent this problem by linking GNU CC with the GNU malloc
  744.      (which thus replaces the malloc that comes with the system).  GNU
  745.      malloc is available as a separate package, and also in the file
  746.      `src/gmalloc.c' in the GNU Emacs 19 distribution.
  747.      If you have installed GNU malloc as a separate library package,
  748.      use this option when you relink GNU CC:
  749.           MALLOC=/usr/local/lib/libgmalloc.a
  750.      Alternatively, if you have compiled `gmalloc.c' from Emacs 19, copy
  751.      the object file to `gmalloc.o' and use this option when you relink
  752.      GNU CC:
  753.           MALLOC=gmalloc.o
  754.